local skynet = require "skynet"
local filelog = require "filelog"
local configdao = require "configdao"
local tabletool = require "tabletool"
skynet.start(function()
	print("Server start")
	skynet.newservice("systemlog")
    local confcentersvr = skynet.newservice("confcenter")
    skynet.call(confcentersvr, "lua", "start")
    print("confcenter start success")
    
    local recordsvrs = configdao.get_svrs("recordsvrs")
    if recordsvrs == nil then
        print("recordsvrd start failed recordsvrs == nil")
        skynet.exit()
    end
    local recordsvr = recordsvrs[skynet.getenv("svr_id")]
    if recordsvr == nil then
        print("recordsvrd start failed recordsvr == nil", skynet.getenv("svr_id"))
        skynet.exit()           
    end

    skynet.newservice("debug_console", recordsvr.debug_console_port)
    
    --加载mq服务
    local recordmqsvrs = configdao.get_svrs("recordmqsvrs")
    if recordmqsvrs ~= nil then
        local tmpconf
        for id, conf in pairs(proxys) do
            local svr = skynet.uniqueservice("proxy", id)
            tmpconf = tabletool.deepcopy(conf)
            tmpconf.svr_id = skynet.getenv("svr_id")
            skynet.call(svr, "lua", "init", tmpconf)            
        end 
    end
        
    local params = ",,,,,"..skynet.getenv("svr_id")
    local svr = skynet.newservice("recordsvrd", params)
    skynet.call(svr, "lua", "cmd", "start", recordsvr)
    
	print("recordsvrd start success")
	skynet.exit()
end)
